package com.longge;

import java.util.Stack;

/**
 * @program: my-code
 * @description:
 * @author: longge
 * @create: 2021-05-09 22:45
 */
public class BalancedStringSplit {

    public int balancedStringSplit(String s) {
        char[] chars = s.toCharArray();
        int cycle = 0,count =0;
        for (char aChar : chars) {
            if (aChar=='L'){
                cycle++;
            }else {
                cycle--;
            }
            if (cycle==0) count++;
        }
        return count;
    }
}
